package po;

import java.io.Serializable;

import enums.UserIdentity;

/**
 * @author LiuHao
 * 
 */
public class UserPO implements Serializable {

	private static final long serialVersionUID = 1L;

	private int id;

	private String username;

	private String password;

	private UserIdentity identity;

	public UserPO(int id, String username, String password,
			UserIdentity identity) {
		this.id = id;
		this.username = username;
		this.password = password;
		this.identity = identity;
	}
	
	public UserPO() {
		this.id = 0;
		this.username = "";
		this.password = "";
		this.identity = UserIdentity.CUSTOMER;
	}

	@Override
	public String toString() {
		return "UserPO [id=" + id + ", username=" + username + ", password="
				+ password + ", identity=" + identity + "]";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + id;
		result = prime * result
				+ ((identity == null) ? 0 : identity.hashCode());
		result = prime * result
				+ ((password == null) ? 0 : password.hashCode());
		result = prime * result
				+ ((username == null) ? 0 : username.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		UserPO other = (UserPO) obj;
		if (username == null) {
			if (other.username != null)
				return false;
		} else if (!username.equals(other.username) || identity != other.identity)
			return false;
		return true;
	}

	public int getId() {
		return id;
	}

	public String getUsername() {
		return username;
	}

	public String getPassword() {
		return password;
	}

	public UserIdentity getIdentity() {
		return identity;
	}

}
